<?php
namespace My\Controller;

use Utuo\BackgroundController;

class DistributionShopGoodsMaterialController extends BackgroundController {
	
	protected $productId = 0;
	
	public function _initialize() {
		$this->productId = I("productId", 0, "intval");
		$this->setControllerTitle("素材管理");
		$this->setActionTitle(array(
				'index' => "素材列表",
				'modify' => "编辑素材",
				'add' => "添加素材",
				'recycle' => "回收站"
		), '', "productId=".$this->productId);
		$this->assign("productId", $this->productId);
		$this->setActionNav('index,add,recycle');
	}
	
	public function getLists( $is_deleted ) {
		$productId = I("productId", 0, "intval");
		$page = $this->getPage ();
		$pagesize = $this->getPageSize ();
		$d = D ( 'DistributionShopGoodsMaterial' );
		$params = array();
		$condition = array (
				'cid' => $this->aid,
				'is_deleted' => $is_deleted,
				'productId' => $productId
		); 
		$goodsList = $d->where ( $condition )->limit ( $pagesize )->page ( $page )->order ( 'id DESC' )->select ();
		$goodsCount = $d->where ( $condition )->count ();
		$this->assign ( 'distributionShopGoodsMaterialLists', $goodsList );
		$this->showPage ( $goodsCount, $pagesize );
		$this->display();
	}
	
	public function addAction() {
		$distributionShopGoodsMaterial = array(
			'productId' => $this->productId,
		);
		$this->assign('distributionShopGoodsMaterial', $distributionShopGoodsMaterial);
		$this->display("save");
	}
	
}